﻿using System;
using CommonTypes.Server.Operations;

namespace CommonTypes.Server
{
    [Serializable]
    public enum ImAliveResponse
    {
        PRIMARY_UNKNOWN,
        OK,
        ERROR
    };

    [Serializable]
    public enum BullyResponse
    {
        OK,
        NO,
        FRESH_SERVER
    };

    public interface IServerToServer
    {
        ImAliveResponse ImAlive( String primaryId, long logicalClock );

        void GenerateTicket( String clientId, DateTime clientNonce );

        bool AcknowledgeTicket( long ticketId, String clientId, long logicalClock );

        bool RegisterClient( String clientId, String clientLocation, long logicalClock );

        bool UnregisterClient( String clientId, long logicalClock );

        BullyResponse ElectPrimary( String serverId );

        void AcknowledgePrimary( String serverId );

        String currentPrimaryId( );

        Operation[ ] SynchronizeServer( long logicalClock );

        TicketGeneration sendCurrentTicket( );

        void registerServer( String serverId );
    }
}